package com.baizhi.service.impl;

import com.baizhi.dao.ClazzDao;
import com.baizhi.entity.Clazz;
import com.baizhi.service.ClazzService;
import com.baizhi.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ClazzServiceImpl implements ClazzService {
    @Override
    public List<Clazz> selectAll() {
        List<Clazz> clazzList=null;
        SqlSession session = null;
        try {
            session = MybatisUtil.getSqlSession();
            ClazzDao cd = session.getMapper(ClazzDao.class);
            clazzList = cd.selectAll();
            session.commit();
        } catch (Exception e) {
            session.rollback();
            throw new RuntimeException(e);
        }finally {
            MybatisUtil.closeSqlSession(session);
        }
        return clazzList;
    }
}
